package com.lazycoffee.lcloancalculator.pages

import com.lazycoffee.lcloancalculator.components.FormButton
import com.lazycoffee.lcloancalculator.components.InputField
import com.tencent.kuikly.core.annotations.Page
import com.tencent.kuikly.core.base.ViewBuilder
import com.tencent.kuikly.core.module.RouterModule
import com.tencent.kuikly.core.nvi.serialization.json.JSONObject
import com.tencent.kuikly.core.pager.Pager
import com.tencent.kuikly.core.utils.urlParams
import com.tencent.kuikly.core.views.View

@Page("Home")
internal class HomePage : Pager() {

    override fun body(): ViewBuilder {
        val ctx = this
        val totalUnit =
        return {
            View {
                attr {
                    marginTop(pagerData.statusBarHeight)
                    paddingTop(15F)
                    paddingLeft(12F)
                    paddingRight(12F)
                }
                InputField {
                    attr {
                        labelText = "贷款金额"
                        placeholder = "请输入贷款金额"
                        isNumber = true
                    }
                }
                InputField {
                    attr {
                        labelText = "贷款利率（单位：%）"
                        placeholder = "请输入贷款利率"
                        isNumber = true
                    }
                }
                InputField {
                    attr {
                        labelText = "贷款期限"
                        placeholder = "请输入贷款期限"
                        isNumber = true
                    }
                }
                View {
                    FormButton {
                        attr {
                            text = "计算"
                        }
                        event {
                            buttonClick {
                                ctx.jumpPage("Result")
                            }
                        }
                    }
                }

            }

        }
    }
    private fun jumpPage(pageName: String) {
        val pageData = JSONObject()
        acquireModule<RouterModule>(RouterModule.MODULE_NAME).openPage(pageName, pageData)
    }
}